﻿using HandyControl.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using ZoneLinePacking.Common;

namespace ZoneLinePacking.Services.Message {
    /// <summary>
    /// 消息服务
    /// </summary>
    public class MessageService : IMessageService {
        #region MessageBox
        public MessageBoxResult Show(MessageBoxInfo info) {
            return HandyControl.Controls.MessageBox.Show(info);
        }

        public MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None, MessageBoxResult defaultResult = MessageBoxResult.None) {
            return HandyControl.Controls.MessageBox.Show(messageBoxText, caption, button, icon, defaultResult);
        }

        public MessageBoxResult Show(Window owner, string messageBoxText, string caption, MessageBoxButton button = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None, MessageBoxResult defaultResult = MessageBoxResult.None) {
            return HandyControl.Controls.MessageBox.Show(owner, messageBoxText, caption, button, icon, defaultResult);
        }

        public MessageBoxResult Ask(string messageBoxText, string caption) {
            return HandyControl.Controls.MessageBox.Ask(messageBoxText, caption);
        }


        public MessageBoxResult Error(string messageBoxText, string caption) {
            return HandyControl.Controls.MessageBox.Error(messageBoxText, caption);
        }

        public MessageBoxResult Fatal(string messageBoxText, string caption) {
            return HandyControl.Controls.MessageBox.Fatal(messageBoxText, caption);
        }

        public MessageBoxResult Info(string messageBoxText, string caption) {
            return HandyControl.Controls.MessageBox.Info(messageBoxText, caption);
        }

        public MessageBoxResult Success(string messageBoxText, string caption) {
            return HandyControl.Controls.MessageBox.Success(messageBoxText, caption);
        }

        public MessageBoxResult Warning(string messageBoxText, string caption) {
            return HandyControl.Controls.MessageBox.Warning(messageBoxText, caption);
        }
        #endregion

        #region Growl
        public void GrowlInfo(string message, string token = null, bool isShowDateTime = false) {
            GrowlInfo growlInfo = new GrowlInfo();
            if (token == null) {
                growlInfo.Token = AppSession.GrowToken;
            }
            growlInfo.WaitTime = 1;
            growlInfo.Message = message;
            growlInfo.ShowDateTime = isShowDateTime;
            HandyControl.Controls.Growl.Info(growlInfo);
        }

        public void GrowSuccess(string message, string token = null, bool isShowDateTime = false) {
            GrowlInfo growlInfo = new GrowlInfo();
            if (token == null) {
                growlInfo.Token = AppSession.GrowToken;
            }
            growlInfo.WaitTime = 1;
            growlInfo.Message = message;
            growlInfo.ShowDateTime = isShowDateTime;
            HandyControl.Controls.Growl.Success(growlInfo);
        }

        public void GrowWarning(string message, string token = null, bool isShowDateTime = false) {
            GrowlInfo growlInfo = new GrowlInfo();
            if (token == null) {
                growlInfo.Token = AppSession.GrowToken;
            }
            growlInfo.WaitTime = 1;
            growlInfo.Message = message;
            growlInfo.ShowDateTime = isShowDateTime;
            HandyControl.Controls.Growl.Warning(growlInfo);
        }

        public void GrowError(string message, string token = null, bool isShowDateTime = false) {
            GrowlInfo growlInfo = new GrowlInfo();
            if (token == null) {
                growlInfo.Token = AppSession.GrowToken;
            }
            growlInfo.WaitTime = 1;
            growlInfo.Message = message;
            growlInfo.ShowDateTime = isShowDateTime;
            HandyControl.Controls.Growl.Error(growlInfo);
        }

        public void GrowAsk(string message, Func<bool, bool> actionBeforeClose, string token = null, bool isShowDateTime = false) {
            GrowlInfo growlInfo = new GrowlInfo();
            if (token == null) {
                growlInfo.Token = AppSession.GrowToken;
            }
            growlInfo.WaitTime = 1;
            growlInfo.Message = message;
            growlInfo.ShowDateTime = isShowDateTime;
            growlInfo.ActionBeforeClose = actionBeforeClose;
            HandyControl.Controls.Growl.Ask(growlInfo);
        }

        #endregion

        #region GrowlGlobal
        public void GrowlInfoGlobal(string message) {
            HandyControl.Controls.Growl.InfoGlobal(message);
        }

        public void GrowSuccessGlobal(string message) {
            HandyControl.Controls.Growl.SuccessGlobal(message);
        }

        public void GrowWarningGlobal(string message) {
            HandyControl.Controls.Growl.WarningGlobal(message);
        }

        public void GrowErrorGlobal(string message) {
            HandyControl.Controls.Growl.ErrorGlobal(message);
        }

        public void GrowAskGlobal(string message, Func<bool, bool> actionBeforeClose) {
            HandyControl.Controls.Growl.AskGlobal(message, actionBeforeClose);
        }
        #endregion
    }
}
